/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.creature.plant.plugin;

import java.awt.Image;
import model.creature.plant.AOEAttackerPlant;
import model.game.GameInterface;
import model.map.cell.PlantableCell;
import model.utility.ImageUtility;

/**
 * Grass greatly damage anyone who step on it once it's planted.
 *
 * Vulnerable to goats.
 * 
 * Cannot be harvested.
 *
 */
public class Grass extends AOEAttackerPlant {

  public Grass(GameInterface game, PlantableCell cell) {
    super(game, cell);
  }

  /**
   * Retrieves the fruit name from this plant when harvested
   */
  @Override
  protected String getFruitName() {
    return null;
  }

  /**
   * Retrieves the days required to go from seed to mature
   */
  @Override
  protected int timeToMature() {
    return 1;
  }

  /**
   * Retrieves the days before this plant dies
   */
  @Override
  protected int timeToDie() {
    return 1000000000;
  }

  /**
   * Retrieves the days before this plant can be harvested from mature state,
   * having beeing harvested harvest_count times before
   */
  @Override
  protected int timeToHarvest(int harvest_count) {
    return 1000000000;
  }

  /**
   * Retrieves the HP of this plant at the given level
   * level can be accessed through getLevel()
   */
  @Override
  protected int getHPAtCurrentLevel() {
    return 30 + getLevel() * 20;
  }

  /**
   * Returns true iff plant can be upgraded again now
   * It's current level is given in getLevel()
   */
  @Override
  public boolean canUpgrade() {
    if (getLevel() < 3) return true;
    return false;
  }

  /**
   * Retrieves the price to upgrade this plant's level
   * It's current level is given in getLevel()
   * @requires canUpgrade()
   */
  @Override
  public int getUpgradeCost() {
    return getLevel() * 75 + 150;
  }

   /**
   * Returns the image sprite of this plant
   */
  @Override
  public Image getImage() {
    if (is_seed_) {
      return ImageUtility.loadImage("resources/pictures/plants/grass/seed.png");
    } else {
      return ImageUtility.loadImage("resources/pictures/plants/grass/mature.png");
    }
  }

  /**
   * Returns the name of this plant
   * Primary Key
   */
  @Override
  public String getName() {
    return "Grass";
  }

  /**
   * Return the season only during this season this plant may grow
   */
  @Override
  public String getSeason() {
    return "Summer";
  }

  /**
   * Returns the description of this plant
   */
  @Override
  public String getDescription() {
    return "Grows in one day in summer. Damages all creatures that step on it"
            + " or is standing on it for damage equal to its HP. Dies in 10"
            + " days. Weak when is attacked directly. Can be stepped on.";
  }

  /**
   * Determines the dmaage done by a creature when attacking
   */
  @Override
  public int getPower() {
    return getHP();
  }

  /**
   * Returns the radius of this plant's attacks
   *
   * I.e., this plant attack at most plantAttackCount() monsters whose
   * manhattan distance with this plant is less than or equal getRadius()
   */
  public int getRadius() {
    return 0;
  }

  /**
   * Returns the number of shots this plant performs each time.
   */
  public int getAttackCount() {
    return 100;
  }

  @Override
  public int getAttackSpeed() {
    return 1;
  }

  @Override
  public boolean isSteppable() {
    return true;
  }

  @Override
  public boolean canAttack() {
    return !is_seed_;
  }

}
